using JGSY.CMS.LowCode.Platform.Application.DTOs;
using JGSY.CMS.LowCode.Platform.Controllers;
using JGSY.CMS.LowCode.Platform.Infrastructure.Upload;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 文件上传服务接口
    /// </summary>
    public interface IFileUploadService
    {
        /// <summary>
        /// 单文件上传
        /// </summary>
        Task<UploadResult> UploadFileAsync(UploadRequest request);

        /// <summary>
        /// 多文件上传
        /// </summary>
        Task<MultipleUploadResult> UploadMultipleFilesAsync(List<UploadRequest> requests);

        /// <summary>
        /// 初始化分片上传
        /// </summary>
        Task<ChunkUploadInitResult> InitChunkUploadAsync(ChunkUploadInitRequest request);

        /// <summary>
        /// 上传文件分片
        /// </summary>
        Task<ChunkUploadResult> UploadChunkAsync(ChunkUploadRequest request);

        /// <summary>
        /// 完成分片上传
        /// </summary>
        Task<UploadResult> CompleteChunkUploadAsync(string uploadId, int userId);

        /// <summary>
        /// 取消分片上传
        /// </summary>
        Task CancelChunkUploadAsync(string uploadId, int userId);

        /// <summary>
        /// 删除文件
        /// </summary>
        Task<bool> DeleteFileAsync(string fileId, int userId);

        /// <summary>
        /// 批量删除文件
        /// </summary>
        Task<BatchDeleteResult> BatchDeleteFilesAsync(List<string> fileIds, int userId);

        /// <summary>
        /// 获取文件信息
        /// </summary>
        Task<FileInfoData?> GetFileInfoAsync(string fileId);

        /// <summary>
        /// 获取文件列表
        /// </summary>
        Task<PagedResult<FileInfoData>> GetFilesAsync(GetFilesRequest request);

        /// <summary>
        /// 生成文件访问令牌
        /// </summary>
        Task<FileAccessTokenResult> GenerateAccessTokenAsync(string fileId, int userId, int expiresInMinutes);

        /// <summary>
        /// 获取上传进度
        /// </summary>
        Task<UploadProgressResult?> GetUploadProgressAsync(string uploadId, int userId);

        /// <summary>
        /// 验证文件类型
        /// </summary>
        bool IsAllowedFileType(string fileName, string contentType);

        /// <summary>
        /// 生成缩略图
        /// </summary>
        Task<string?> GenerateThumbnailAsync(string filePath, string fileName);

        /// <summary>
        /// 获取文件访问URL
        /// </summary>
        Task<string> GetFileUrlAsync(string fileId, bool isPrivate = false);
    }
}
